package com.ytd.common.bean;

import android.text.TextUtils;

/**
 * 网络请求返回
 *
 * @author gaoguanchao
 * @since 2023/4/14
 */
public class BaseResponse {
    private static final String SUCCESS_CODE = "0";
    private static final String SERVER_ERROR = "11";
    private static final String OFFLINE_CODE = "offline";
    public String interfaceName;
    public String code;
    public Object data;
    public String msg;
    public String requestId;

    public boolean isSuccess() {
        return SUCCESS_CODE.equals(code);
    }

    public boolean isServerError() {
        return SERVER_ERROR.equals(code);
    }

    public boolean isOffline() {
        return OFFLINE_CODE.equals(code);
    }

    public boolean isPush() {
        return !TextUtils.isEmpty(code) && !TextUtils.isDigitsOnly(code);
    }

    @Override
    public String toString() {
        return "BaseResponse{" +
            "interfaceName='" + interfaceName + '\'' +
            ", code='" + code + '\'' +
            ", msg='" + msg + '\'' +
            ", requestId='" + requestId + '\'' +
            '}';
    }
}
